package com.iris.live.services.services.impl;

import com.iris.live.services.data.models.调入付款详单Model;
import com.iris.live.services.data.models.调出收款详单Model;
import com.iris.live.services.data.models.财务开票Model;
import com.iris.live.services.data.models.财务详单Model;
import com.iris.live.services.data.repositories.*;
import com.iris.live.services.models.PageData;
import com.iris.live.services.services.InvoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import java.util.List;

/**
 * Created by shixy on 2016/8/12.
 */
@Service
@Transactional//(readOnly = true)
public class InvoiceServiceImpl implements InvoiceService {

    @Autowired
    private InvoiceRepository repository;

    @Autowired
    private 调入付款详单Repository 调入付款详单Repository;

    @Autowired
    private 调出收款详单Repository 调出收款详单Repository;

    @Autowired
    private 财务开票Repository 财务开票Repository;

    @Autowired
    private 财务详单Repository 财务详单Repository;

    @Override
    public PageData getInvoiceFinancialOperationList(String permit,GetInvoiceFinancialOperationListRequest request) {
        return repository.getInvoiceFinancialOperationList(permit,request);
    }

    @Override
    public PageData getCollectionList(String permit,InvoiceService.getCollectionListRequest request) {
        return repository.getCollectionList(permit,request);
    }

    @Override
    public PageData getPaymentList(String permit,getPaymentListRequest request) {
        return repository.getPaymentList(permit,request);
    }

    @Override
    public PageData getSaleCollectionList(String permit,getSaleCollectionListRequest request) {
        return repository.getSaleCollectionList(permit,request);
    }

    @Override
    @Transactional
    public 调入付款详单Model savePayment(调入付款详单Model model) {
        Assert.notNull(model);
        return this.调入付款详单Repository.save(model);
    }

    @Override
    @Transactional
    public List<调入付款详单Model> savePaymentBatch(List<调入付款详单Model> modelList) {
        Assert.notNull(modelList);
        return this.调入付款详单Repository.save(modelList);
    }

    @Override
    @Transactional
    public 调出收款详单Model saveCollection(调出收款详单Model model) {
        Assert.notNull(model);
        return this.调出收款详单Repository.save(model);
    }

    @Override
    @Transactional
    public List<调出收款详单Model> saveCollectionBatch(List<调出收款详单Model> modelList) {
        Assert.notNull(modelList);
        return this.调出收款详单Repository.save(modelList);
    }

    @Override
    @Transactional
    public 财务开票Model saveInvoice(财务开票Model model) {
        Assert.notNull(model);
        return this.财务开票Repository.save(model);
    }

    @Override
    @Transactional
    public List<财务开票Model> saveInvoiceBatch(List<财务开票Model> modelList) {
        Assert.notNull(modelList);
        return this.财务开票Repository.save(modelList);
    }

    @Override
    @Transactional
    public 财务详单Model saveDetails(财务详单Model model) {
        Assert.notNull(model);
        return this.财务详单Repository.save(model);
    }

    @Override
    @Transactional
    public List<财务详单Model> saveDetailsBatch(List<财务详单Model> modelList) {
        Assert.notNull(modelList);
        return this.财务详单Repository.save(modelList);
    }
}
